package com.ffyc.resale.dao;

import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface DataDao {


    @Select("select name from good_type order by id asc")
    List<String> goodsTypeName();

    @Select("SELECT \n" +
            "    COUNT(b.id) AS transaction_count      -- 该分类商品的交易次数\n" +
            "FROM \n" +
            "    good_type gt\n" +
            "LEFT JOIN \n" +
            "    goods g ON gt.id = g.typeid           -- 关联商品表\n" +
            "LEFT JOIN \n" +
            "    buy b ON g.id = b.goodsid             -- 关联交易表\n" +
            "GROUP BY \n" +
            "    gt.id, gt.name                        -- 按商品分类分组\n" +
            "ORDER BY \n" +
            "    gt.id;                                -- 按分类ID排序")
    List<Integer> goodsTypeBuyCount();

    List<Map<String,Integer>> goodsCountPie();

}
